import random

from core.models import Rating, Restaurant, Sale, Staff, StaffRestaurant
from django.contrib.auth.models import User
from django.utils import timezone
from django.db.models import Avg, Value, CharField, Sum, Count, F, Q
from django.db.models.functions import Lower, Concat, Coalesce


def run():
    restaurants = Restaurant.objects.order_by('capacity').values('capacity')
    print(restaurants)
    restaurants = Restaurant.objects.order_by('-capacity').values('capacity')
    print(restaurants)
    restaurants = Restaurant.objects.order_by(F('capacity')).values('capacity')
    print(restaurants)
    restaurants = Restaurant.objects.order_by(-F('capacity')).values('capacity')
    print(restaurants)
    res = Restaurant.objects.aggregate(total_cap=Coalesce(Sum('capacity'), 0))
    print(res)
    print('1111')
    print(Rating.objects.filter(rating__lt=0).aggregate(total=Coalesce(Avg('rating'), 0.0)))
    print(Restaurant.objects.annotate(name_value=Coalesce(F('nickname'), F('name'))).values('name_value'))


